package com.design.iterator;

public class ClassRoom implements Aggregate{

    private Student[] students;
    private int length=0;
    private int maxSize;

    public ClassRoom(int maxSize){
        this.maxSize=maxSize;
        students=new Student[maxSize];
    }

    public Student getStudent(int index){
        return students[index];
    }

    public boolean addStudent(Student student){
        if (length>=maxSize){
            return false;
        }
        this.students[length]=student;
        length++;
        return true;
    }

    public int getLength(){
        return this.length;
    }






    @Override
    public TIerator ierator() {
        return new ClassRoomIterator(this);
    }
}
